//
//  ICMBalanceInfoView.m
//  ICrEAM
//
//  Created by kuroro on 16/11/24.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMBalanceInfoView.h"


@interface ICMBalanceInfoView()<ICMTitleTextFeildViewDelegate>
@property (nonatomic, strong) TPKeyboardAvoidingScrollView *bigScrollView;

@property (nonatomic, strong) NSTimer *timer;

@end
#define xDistanceA                  ActualWidth(30)
#define xDistanceB                  ActualWidth(50)
#define yDistance                   (ScreenHeight-240-7*TitleTFViewHeight)/8
#define TitleTFViewHeight           ActualHeight(58)
#define TitleTViewHeight            ActualHeight(90)

static  int verificationTime = 60;

@implementation ICMBalanceInfoView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self){
        self.frame = frame;
        self.bigScrollView = [[TPKeyboardAvoidingScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame))];
        self.bigScrollView.backgroundColor = [UIColor clearColor];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeAccounts:) name:@"CalculateRatioPrice" object:nil];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUseCoupon:) name:@"CalculateUseCoupon" object:nil];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFraction:) name:@"CalculateFraction" object:nil];
        
        
        self.backgroundColor = BackgroundColor_White;
        //第一行
        ICMTitleTextFeildView *cardNoView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(ActualWidth(20), yDistance, ActualWidth(180), TitleTFViewHeight) title:@"会员卡号"];
        [self.bigScrollView addSubview:cardNoView];
        
        
        ICMTitleTextFeildView *withholdIntegralView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(cardNoView.rightEdge+xDistanceA, cardNoView.y, ActualWidth(150), TitleTFViewHeight) title:@"预扣积分"];
        [self.bigScrollView addSubview:withholdIntegralView];
        
        ICMTitleTextFeildView *exchangeAmountView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(withholdIntegralView.rightEdge+xDistanceA, withholdIntegralView.y, ActualWidth(150), TitleTFViewHeight) title:@"兑换金额"];
        [self.bigScrollView addSubview:exchangeAmountView];
        
        ICMTitleTextFeildView *memberIDView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewRedWithFrame:CGRectMake(exchangeAmountView.rightEdge+xDistanceB, withholdIntegralView.y, ActualWidth(180), TitleTFViewHeight) title:@"会员编号"];
        [self.bigScrollView addSubview:memberIDView];
        
        ICMTitleTextFeildView *SSTIntegralAmountView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewRedWithFrame:CGRectMake(memberIDView.rightEdge+xDistanceA, withholdIntegralView.y, ActualWidth(180), TitleTFViewHeight) title:@"可用积分金额"];
        [self.bigScrollView addSubview:SSTIntegralAmountView];
        
        self.cardNoView = cardNoView;
        self.withholdIntegralView = withholdIntegralView;
        self.exchangeAmountView = exchangeAmountView;
        self.memberIDView = memberIDView;
        self.SSTIntegralView = SSTIntegralAmountView;
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, cardNoView.y-ActualHeight(8), ScreenWidth, 1)];
        lineView.backgroundColor = SepColor_gray;
        [self.bigScrollView addSubview:lineView];
        UILabel *VWLabel = [[UILabel alloc]initWithFrame:CGRectMake(cardNoView.x,lineView.y-6 ,ActualWidth(60) , 15)];
        VWLabel.font = ContentFont;
        VWLabel.textColor = SepColor_gray;
        VWLabel.backgroundColor = BackgroundColor_White;
        VWLabel.text = @"大众一家";
        [self.bigScrollView addSubview: VWLabel];
        UILabel *SSTLabel = [[UILabel alloc]initWithFrame:CGRectMake(memberIDView.x, VWLabel.y, ActualWidth(70), 15)];
        SSTLabel.textColor = SepColor_gray;
        SSTLabel.backgroundColor = BackgroundColor_White;
        SSTLabel.font = ContentFont;
        SSTLabel.text = @"经销商会员";
        [self.bigScrollView addSubview:SSTLabel];
        
        //第二行
        ICMTitleTextFeildView *VWIntegralAmountView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(cardNoView.x, cardNoView.bottomEdge+yDistance, ActualWidth(180), TitleTFViewHeight) title:@"可用积分金额"];
        [self.bigScrollView addSubview:VWIntegralAmountView];
        
        ICMTitleTextFeildView *VWIntegralView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(withholdIntegralView.x, VWIntegralAmountView.y, ActualWidth(150), TitleTFViewHeight) title:@"可用积分"];
        [self.bigScrollView addSubview:VWIntegralView];
        
        ICMTitleTextFeildView *barcodeView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewRedWithFrame:CGRectMake(memberIDView.x, VWIntegralAmountView.y, ActualWidth(180), TitleTFViewHeight) title:@"实物卡条码"];
        [self.bigScrollView addSubview:barcodeView];
        
        ICMTitleTextFeildView *labourHourIntegralView = [ICMTitleTextFeildView createEditableICMTitleTextFeildViewWithFrame:CGRectMake(SSTIntegralAmountView.x, VWIntegralAmountView.y, ActualWidth(180), TitleTFViewHeight) title:@"工时抵用积分金额"];
        labourHourIntegralView.contentTextFeild.keyboardType = UIKeyboardTypeNumberPad;
        labourHourIntegralView.delegate = self;
        [self.bigScrollView addSubview:labourHourIntegralView];
        
        self.VWIntegralAmountView = VWIntegralAmountView;
        self.VWIntegralView = VWIntegralView;
        self.barcodeView = barcodeView;
        self.SSTIntegralAmountView = SSTIntegralAmountView;
        self.labourHourIntegralView = labourHourIntegralView;
        
        
        //第三行
        ICMTitleTextFeildView *VWUseIntegralView = [ICMTitleTextFeildView createEditableICMTitleTextFeildViewWithFrame:CGRectMake(VWIntegralAmountView.x, VWIntegralAmountView.bottomEdge+yDistance, ActualWidth(180), TitleTFViewHeight) title:@"本次使用积分金额"];
        VWUseIntegralView.delegate = self;
        VWUseIntegralView.contentTextFeild.keyboardType = UIKeyboardTypeNumberPad;
        [self.bigScrollView addSubview:VWUseIntegralView];
        
        ICMTitleTextFeildView *verificationView = [ICMTitleTextFeildView createEditableICMTitleTextFeildViewWithFrame:CGRectMake(VWIntegralView.x, VWUseIntegralView.y, ActualWidth(150), TitleTFViewHeight) title:@"验证码"];
        verificationView.contentTextFeild.keyboardType = UIKeyboardTypeNumberPad;
        [self.bigScrollView addSubview:verificationView];
        
        ICMTitleTextFeildView *SSTIntegralView = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(barcodeView.x, VWUseIntegralView.y, ActualWidth(180), TitleTFViewHeight) title:@"可用积分"];
        [self.bigScrollView addSubview:SSTIntegralView];
        
        ICMTitleTextFeildView *partIntegralView = [ICMTitleTextFeildView createEditableICMTitleTextFeildViewWithFrame:CGRectMake(labourHourIntegralView.x, VWUseIntegralView.y, ActualWidth(180), TitleTFViewHeight) title:@"材料抵用积分金额"];
        partIntegralView.contentTextFeild.keyboardType = UIKeyboardTypeNumberPad;
        partIntegralView.delegate = self;
        [self.bigScrollView addSubview:partIntegralView];
        
        self.VWUseIntegralView = VWUseIntegralView;
        self.verificationView = verificationView;
        self.SSTIntegralView = SSTIntegralView;
        self.partIntegralView = partIntegralView;
        
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, partIntegralView.bottomEdge+ActualHeight(14), ScreenWidth, 1)];//第三行底部分割线
        line1.backgroundColor = SepColor_gray;
        [self.bigScrollView addSubview:line1];
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(memberIDView.x-xDistanceA, lineView.y, 1, line1.bottomEdge-lineView.y)];//中间分割线
        line2.backgroundColor = SepColor_gray;
        [self.bigScrollView addSubview:line2];
        
        
        
        //第四行
        
        ICMTitleSubTitleView *nameView = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"付费方名称" subtitle:@"" frame:CGRectMake(VWUseIntegralView.x, VWUseIntegralView.bottomEdge+yDistance+ActualHeight(10), ActualWidth(180), TitleTFViewHeight)];
        [self.bigScrollView addSubview:nameView];
        
        ICMTitleSubTitleView *labourAccounts = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"应收工时费" subtitle:@"" frame:CGRectMake(verificationView.x, nameView.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:labourAccounts];
        
        ICMTitleSubTitleView *partAccounts = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"应收材料费" subtitle:@"" frame:CGRectMake(labourAccounts.rightEdge, nameView.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:partAccounts];
        
        ICMTitleSubTitleView *amountAccounts = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"应收总金额" subtitle:@"" frame:CGRectMake(partAccounts.rightEdge, nameView.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:amountAccounts];
        
        self.nameView = nameView;
        self.labourAccounts = labourAccounts;
        self.partAccounts = partAccounts;
        self.amountAccounts = amountAccounts;
        
        //第五行
        
        ICMTitleSubTitleView *labourRealPrice = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"实收工时费" subtitle:@"" frame:CGRectMake(labourAccounts.x, nameView.bottomEdge+yDistance, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:labourRealPrice];
        
        ICMTitleSubTitleView *partRealPrice = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"实收材料费" subtitle:@"" frame:CGRectMake(partAccounts.x, labourRealPrice.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:partRealPrice];
        
        ICMTitleSubTitleView *amountRealPrice = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"实收总金额" subtitle:@"" frame:CGRectMake(amountAccounts.x, labourRealPrice.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:amountRealPrice];
        
        
        self.labourRealPrice = labourRealPrice;
        self.partRealPrice = partRealPrice;
        self.amountRealPrice = amountRealPrice;
        
        //第六行
        
        ICMTitleSubTitleView *labourDeduction = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"工时券抵扣金额" subtitle:@"" frame:CGRectMake(labourAccounts.x, labourRealPrice.bottomEdge+yDistance, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:labourDeduction];
        
        ICMTitleSubTitleView *partDeduction = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"材料券抵扣金额" subtitle:@"" frame:CGRectMake(partAccounts.x, labourDeduction.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:partDeduction];
        
        ICMTitleSubTitleView *amountDeduction = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"去零金额" subtitle:@"" frame:CGRectMake(amountAccounts.x, labourDeduction.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:amountDeduction];
        
        self.labourDeduction = labourDeduction;
        self.partDeduction = partDeduction;
        self.amountDeduction = amountDeduction;
        
        
        //第七行
        
        ICMTitleSubTitleView *accounts = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"应收账款" subtitle:@"100" frame:CGRectMake(labourAccounts.x, labourDeduction.bottomEdge+yDistance, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:accounts];
        
        ICMTitleSubTitleView *tax = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"税额" subtitle:@"" frame:CGRectMake(partAccounts.x, accounts.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:tax];
        
        ICMTitleSubTitleView *endAmount = [ICMTitleSubTitleView createICMTitleSubTitleViewWithTitle:@"不含税金额" subtitle:@"" frame:CGRectMake(amountAccounts.x, accounts.y, ActualWidth(260), TitleTFViewHeight)];
        [self.bigScrollView addSubview:endAmount];
        
        self.accounts = accounts;
        self.tax = tax;
        self.endAmount = endAmount;
        
        UIButton *memberBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        memberBtn.frame = CGRectMake(cardNoView.x+ActualWidth(160), cardNoView.y, ActualWidth(23), ActualWidth(23));
        [memberBtn setUpButtonWithNormolTitle:nil selectedTitle:nil normolTitleSize:0 selectedTitleSize:0 normolTitleColor:nil selectedTitleColor:nil normolBcakImage:[UIImage imageNamed:GetCar_Synchronize] selectedBackImage:nil actionSEL:@selector(clickMemberBtn) target:self];
        [self.bigScrollView addSubview:memberBtn];
        [ICrEAMTool createAndAddBiggerButtonForButton:memberBtn andSEL:@selector(clickMemberBtn) target:self addTop:15 bottom:0 left:15 right:15 inView:self.bigScrollView ];
        
        UIButton *verificationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        verificationBtn.frame = CGRectMake(exchangeAmountView.x, verificationView.bottomEdge-ActualHeight(35), ActualWidth(150), ActualHeight(35));
        verificationBtn.backgroundColor = TitleColor;
        verificationBtn.layer.cornerRadius = 4;
        verificationBtn.layer.masksToBounds = YES;
        [verificationBtn setUpButtonWithNormolTitle:@"短信验证码" selectedTitle:@"短信验证码" normolTitleSize:20 selectedTitleSize:20 normolTitleColor:[UIColor whiteColor] selectedTitleColor:[UIColor whiteColor] normolBcakImage:nil selectedBackImage:nil actionSEL:@selector(clickVerificationBtn) target:self];
        [self.bigScrollView addSubview:verificationBtn];
        self.verificationBtn = verificationBtn;
        self.verificationBtn.alpha = 0.5;
        self.verificationBtn.enabled = NO;
        
        self.bigScrollView.contentSize = CGSizeMake(ScreenWidth, accounts.bottomEdge);
        [self addSubview:self.bigScrollView];
    }
    return self;
}


+ (instancetype)createICMBalanceInfoViewWithFrame:(CGRect)frame{
    return [[ICMBalanceInfoView alloc] initWithFrame:frame];
}

#pragma mark -- 界面赋值
- (void)setBalanceInfoViewWithModel:(ICMBalanceBasicInfoModel *)model{
    self.cardNoView.contentText = model.HQ_VW_CARD_ID;
    self.HQ_VW_CARD_TYPE = model.CARD_TYPE_NAME;
    self.MEMBER_PROPERTY_NAME = model.MEMBER_PROPERTY_NAME;
    self.withholdIntegralView.contentText = model.CONVERT_SCORE;
    self.exchangeAmountView.contentText = model.PART_SALES_AMOUNT;
    self.memberIDView.contentText = model.MEMBER_NO;
    if (!model.MEMBER_NO) {
        self.labourHourIntegralView.userInteractionEnabled = NO;
        self.labourHourIntegralView.borderView.backgroundColor = TextFeildBackgroundColor_Gray;
        self.partIntegralView.userInteractionEnabled = NO;
        self.partIntegralView.borderView.backgroundColor = TextFeildBackgroundColor_Gray;
    }
    if (!StrIsZero_gdm(model.CREDIT_BALANCE) && !StrIsZero_gdm(model.SVW_CREDIT_AMOUNT_FACTOR)) {
        double creditBalance = [model.CREDIT_BALANCE doubleValue];
        double factor = [model.SVW_CREDIT_AMOUNT_FACTOR doubleValue];
        self.SSTIntegralAmountView.contentText = [NSString stringWithFormat:@"%.2f",creditBalance/factor];
    }
    self.CARD_ID = model.CARD_ID;
    
    //    self.VWIntegralAmountView.contentText = VWIntegralAmountView;
    //    self.VWIntegralView.contentText = VWIntegralView;
    self.barcodeView.contentText = model.BAR_CODE;
    
    self.SSTIntegralView.contentText = model.CREDIT_BALANCE;
    self.nameView.subtitleLabel.text = model.OWNER_NAME;
    if ([model.RO_REPAIR_TYPE_NAME isEqualToString:@"质量担保保养"]) {
        self.nameView.subtitleLabel.text = @"上汽大众";
    }
    self.labourAccounts.subtitleLabel.text = model.LABOUR_AMOUNT?:@"0";
    self.partAccounts.subtitleLabel.text = model.REPAIR_PART_AMOUNT?:@"0";
    self.amountAccounts.subtitleLabel.text = model.REPAIR_AMOUNT?:@"0";
    
    self.labourRealPrice.subtitleLabel.text = @"0";
    self.partRealPrice.subtitleLabel.text = @"0";
    self.amountRealPrice.subtitleLabel.text = @"0";
    
    self.labourDeduction.subtitleLabel.text = @"0";
    self.partDeduction.subtitleLabel.text = @"0";
    self.amountDeduction.subtitleLabel.text = @"0";
    self.model = model;
    [self getAccounts];
}

#pragma mark -- 结算计算
- (void)getAccounts{
    //实收总金额
    double amountRealPrice = [self.amountRealPrice.subtitleLabel.text doubleValue];
    //工时卷抵扣金额
    double labourDeduction = [self.labourDeduction.subtitleLabel.text doubleValue];
    //材料卷抵扣金额
    double partDeduction = [self.partDeduction.subtitleLabel.text doubleValue];
    //去零金额
    double amountDeduction = [self.amountDeduction.subtitleLabel.text doubleValue];
    //本次使用积分金额
    double VWUseIntegral = [self.VWUseIntegralView.contentText doubleValue];
    //工时抵用金额
    double labourHourIntegral = [self.labourHourIntegralView.contentText doubleValue];
    //材料抵用积分金额
    double partIntegral = [self.partIntegralView.contentText doubleValue];
    //总金额
    double accountsDesc = amountRealPrice-labourDeduction-partDeduction-labourHourIntegral-VWUseIntegral-partIntegral;
    //应收账款金额
    NSString *receivableAmount = [ICrEAMTool resultAboutAmoun:accountsDesc];
    self.accounts.desc = [NSString stringWithFormat:@"%.2f",[receivableAmount doubleValue]];
    //圆整金额 圆整前减圆整后
    self.RMBAmount = [NSString stringWithFormat:@"%.2f",accountsDesc -[receivableAmount doubleValue]];
    //应收账款
    double accounts = [receivableAmount doubleValue] - amountDeduction;
    
    self.accounts.subtitleLabel.text = [NSString stringWithFormat:@"%.2f",accounts];
    
    //税率计算
    //先圆整实收账款
    NSString *RMBRealPriceString = [ICrEAMTool resultAboutAmoun:amountRealPrice];
    double RMBRealPrice = [RMBRealPriceString doubleValue];
    double tax = RMBRealPrice - (RMBRealPrice / 1.17);
    self.tax.subtitleLabel.text = [NSString stringWithFormat:@"%.2f",tax];
    double endAmount = RMBRealPrice - tax;
    self.endAmount.subtitleLabel.text = [NSString stringWithFormat:@"%.2f",endAmount];
}




#pragma mark -- 通知回调点击
//积分余额判断
- (void)editableViewDidEndEdit:(ICMTitleTextFeildView *)sender{
    if (sender == self.VWUseIntegralView) {
        if ([self.VWUseIntegralView.contentText doubleValue] > [self.VWIntegralAmountView.contentText doubleValue]) {
            [self showString:@"积分不足" forSeconds:1.5];
            self.VWUseIntegralView.contentText = @"";
        }else{
            [self getAccounts];
        }
        
    }else if (sender == self.labourHourIntegralView || sender == self.partIntegralView){
        if (([self.labourHourIntegralView.contentText doubleValue] + [self.partIntegralView.contentText doubleValue]) > [self.SSTIntegralAmountView.contentText doubleValue]) {
            [self showString:@"积分不足" forSeconds:1.5];
            if (sender == self.labourHourIntegralView) {
                self.labourHourIntegralView.contentText = @"";
            }else{
                self.partIntegralView.contentText = @"";
            }
        }else if ([self.labourHourIntegralView.contentText doubleValue] > [self.labourRealPrice.subtitleLabel.text doubleValue]){
            [self showString:@"工时抵用积分金额应小于实收工时费" forSeconds:1.5];
            if (sender == self.labourHourIntegralView) {
                self.labourHourIntegralView.contentText = @"";
            }else{
                self.partIntegralView.contentText = @"";
            }
        }else if ([self.partIntegralView.contentText doubleValue] > [self.partRealPrice.subtitleLabel.text doubleValue]){
            [self showString:@"材料抵用积分金额应小于实收材料费" forSeconds:1.5];
            if (sender == self.labourHourIntegralView) {
                self.labourHourIntegralView.contentText = @"";
            }else{
                self.partIntegralView.contentText = @"";
            }
        }else{
            [self getAccounts];
        }
    }
}

#pragma mark -- 点击同步会员
- (void)clickMemberBtn{
    if ([self.delegate respondsToSelector:@selector(clickMemberBtn)]) {
        [self.delegate clickMemberBtn];
    }
}

#pragma mark -- 点击验证码

- (void)startTimer{
    if (!self.timer) {
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFire) userInfo:nil repeats:YES];
    }
}
- (void)clickVerificationBtn{
    if ([self.delegate respondsToSelector:@selector(clickVerificationBtn)]) {
        [self.delegate clickVerificationBtn];
    }
}

#pragma mark -- 金额计算通知
- (void)changeAccounts:(NSNotification *)notification{
    NSDictionary *dic = [notification userInfo];
    self.labourRealPrice.subtitleLabel.text = dic[@"ratioEventPrice"]?:@"0";
    self.partRealPrice.subtitleLabel.text = dic[@"ratioPartPrice"]?:@"0";
    self.amountRealPrice.subtitleLabel.text = dic[@"DiscountedPrice"]?:@"0";
    self.labourAccounts.subtitleLabel.text = dic[@"workingPrice"]?:@"0";
    self.partAccounts.subtitleLabel.text = dic[@"partsPrice"]?:@"0";
    self.amountAccounts.subtitleLabel.text = dic[@"totalPrice"]?:@"0";
    [self getAccounts];
}

#pragma mark -- 优惠券抵扣通知
- (void)changeUseCoupon:(NSNotification *)notification{
    NSDictionary *dic = [notification userInfo];
    self.partDeduction.subtitleLabel.text = dic[@"PartUval"];
    self.labourDeduction.subtitleLabel.text = dic[@"LabourUval"];
    [self getAccounts];
}

#pragma mark -- 去零通知
- (void)changeFraction:(NSNotification *)notification{
    NSDictionary *dic = [notification userInfo];
    self.amountDeduction.subtitleLabel.text = dic[@"fraction"];
    [self getAccounts];
}



- (void)timerFire{
    verificationTime--;
    if (verificationTime <= 0) {
        verificationTime = 60;
        [self.verificationBtn setTitle:@"短信验证码" forState:UIControlStateNormal];
        self.verificationBtn.userInteractionEnabled = YES;
        [self.timer invalidate];
        self.timer = nil;
    }else{
        self.verificationBtn.userInteractionEnabled = NO;
        [self.verificationBtn setTitle:[NSString stringWithFormat:@"%ds后重新获取",verificationTime] forState:UIControlStateNormal];
    }
}



-(void)dealloc{
    [self.timer invalidate];
    self.timer = nil;
}

#pragma 页面值变化
//值变化调用此方法
- (void)iCMTitleTextFeildViewValueChanged
{
    self.hasViewValueChanged = YES;
}

//值变化调用此方法
- (void)iCMTitleTextViewValueChanged
{
    self.hasViewValueChanged = YES;
}

- (void)setHasViewValueChanged:(BOOL)hasViewValueChanged
{
    _hasViewValueChanged = hasViewValueChanged;
    if(_hasViewValueChanged)
    {
        //发送变化通知
        [[NSNotificationCenter defaultCenter] postNotificationName:@"BalanceViewValueChanged" object:self];
    }
}

@end
